
#ifndef TEXTURED_POLYGON_H
#define TEXTURED_POLYGON_H

// INCLUDES ********************************************************************

#include "Drawable.h"

#include "Color.h"

// FORWARD DECLARATIONS ********************************************************

namespace Meteor
{
    class Texture2D;
}

// *****************************************************************************

//! TexturedPolygon
//! 
//! Abitrary shape filled with a texture.

// *****************************************************************************

namespace Meteor 
{
    class TexturedPolygon : public Drawable
    {
        public:
            TexturedPolygon( const std::string& textureFileName, 
                             const std::vector<Vector2D>& shapeVertices);
        
            TexturedPolygon( const TexturedPolygon&);
        
            ~TexturedPolygon();
            
            void SetStroke( const Color& color, const float width);
            
            void DisableStroke();
            
            void Update( const float deltaTime);
            
            void Draw() const;
        
        private:
            //! the associated image as an opengl texture
            Texture2D* mTexture;
        
            //! the texture coordinates calculated from the the 
            //! trinagulated vertices
            std::vector<Vector2D> mTextureVertices;
        
            //! this stores the triangulated vertices
            std::vector<Vector2D> mTriangulatedVertices;
        
            //! vertices of the polygon to be filled
            std::vector<Vector2D> mShapeVertices;
            
            //! load the image file and setup our texture
            void Initialize( const std::string& fileName);
            
            //! make necessary triangulation and calculate texture coordinates 
            void CalculateVertices( const std::vector<Vector2D>& shapeVertices);
            
            //! polygons may have a stroke
            bool mHasStroke;
            
            Color mStrokeColor;
            
            float mStrokeWidth;
            
            //! shape used to draw the stroke
            std::vector<Vector2D> mShape;
            
    }; // end of class TexturedPolygon

} // end of namespace Meteor

#endif
